package system;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import bean.MediaBean;

/**
 * Class that implements a Movie
 * @author Otavio Lima, Laura Dutra
 *
 */
public class Movie extends Media {

	private static String mediaId = "mov";

	
	/**
	 * Constructor
	 * @param id - id of movie
	 * @param url - data of movie
	 * @param description - description of movie
	 */
	public Movie(String id, String url, String description) {
		super(id, url, description);
	}
	
	/**
	 * Returns a list of medias of post passed as parameter
	 * @param postId
	 * @return list of media
	 */
	public static List<Media> getMovieByPost(String postId){


		List<Media> mediasByPost = new ArrayList<Media>();
		List<MediaBean> list = mediaDao.list();
		MediaBean media;
		for(Iterator<MediaBean> it = list.iterator(); it.hasNext();){
			media = it.next();
			if(media.getID().contains(postId)){
				if(media.getID().contains(mediaId))
					mediasByPost.add(new Movie(media.getID(), media.getURL(), media.getDescription()));

			}

		}
		return mediasByPost;
	}
}

